<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生系统主页</title>
    <link href="bootstrap-4.6.1-dist/css/bootstrap.css"
          rel="stylesheet" type="text/css">
    <style>
        .dropdown{
            margin-bottom: -20px;
        }
        .dropdown:hover{
            margin: 0px;
        }
        .show{
            /*display: block;*/
            overflow: hidden;
            visibility: hidden;
            max-height: 0px;
            transform: scaleY(0);
        }
        .dropdown:hover .show {
            visibility: visible;
            transition: transform 0.2s;
            max-height: 999999px;
            transform: scaleY(1);
        }
        .userPortrait {
            width: 40px;
            height: 40px;
            border: 1px solid red;
            border-radius: 50%;
            overflow: hidden;
            margin: 0 auto;
            /*margin-top: 100px;*/
        }
        .userPortrait img {
            display: block;
            width: 100%;
            height:100%;
            border: 1px solid green;
        }
        .thing{
            width: 100%;
            height:640px;
        }
        .welcome{
            width: 100%;
            height: 160px;
            float: left;
        }
        .homework{
            width: 100%;
            height: 320px;
            float: left;
        }
    </style>
</head>
<body>

<!--眉头-->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
    <a class="navbar-brand col-1 text-center" href="index.html">爱思教育</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link active" href="userInformation.html">查询和修改个人信息</a>
            </li>
            <li class="nav-item active dropdown">
                <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    查看作业
                </a>
                <div class="dropdown-menu show" aria-labelledby="navbarDropdownMenuLink" id="homework">
                    <a class="dropdown-item" href="studentFinishedHomework.html">已完成作业</a>
                    <a class="dropdown-item" href="studentSelectHomework.html">未完成作业</a>
                </div>
            </li>
            <li class="nav-item active dropdown">
                <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                    查询考试
                </a>
                <div class="dropdown-menu show" aria-labelledby="navbarDropdownMenuLink" id="exam">
                    <a class="dropdown-item" href="studentExaminationInformation.html">查询考试信息</a>
                    <a class="dropdown-item" href="studentScore.html">查询考试成绩</a>
                </div>
            </li>
        </ul>
    </div>
    <div class="userPortrait active dropdown">
        <a href="userInformation.html"><img src="img/defaultPortrait.jpg" alt=""></a>
    </div>
</nav>

<!--中间-->
<div class="row">
    <!--侧边栏-->
    <ul class="navbar-nav bg-light text-center col-md-2">
        <li class="nav-item">
            <a class="nav-link btn btn-light" href="#">消息列表</a>
        </li>
    </ul>
    <div class="main col-10">
        <div class="main col-10 welcome">
            <font face="隶书" size="+4" color=black> 同学你好，欢迎使用教务系统</font><br/>
            <form id="form">
                <table>
                    <tr>
<!--                        <td>学科名：</td>-->
<!--                        <td>-->
<!--                            <input type="text" class="col-8" name="userName">-->
<!--                        </td>-->
<!--                        <td>学科编号：</td>-->
<!--                        <td>-->
<!--                            <input type="text" class="col-8" name="userName">-->
<!--                        </td>-->

                        <td>请输入账号查询考试成绩：</td>
                        <td>
                            <input type="text" class="col-8" name="userPhone" id="userPhone">
                        </td>
                        <td>
                            <button class="btn btn-primary  align-content-center text-center" type="button" id="btnSearch1">查询</button>
                        </td>
                    </tr>
                </table>
            </form>
        </div>

        <div class="main col-10 homework">
            <table class="table table-hover table-bordered">
                <thead class="thead-light">
                <tr>
                    <th scope="col">学科编号</th>
                    <th scope="col">学科名</th>
                    <th scope="col">考试成绩</th>
                    <th scope="col">授课老师</th>
                </tr>
                </thead>
                <tbody id="tbody">

                <tr>
                    <td colspan="4" class="text-center">成绩信息</td>
                </tr>

                </tbody>
            </table>
        </div>
    </div>
</div>


<!--页脚-->
<div class="footer bg-primary fixed-bottom text-center">
    <p class="text-white">版权所有© Copyright 1999-2021 爱思软件股份有限公司　　中国·青岛黄岛区嘉陵江路777号 西区公寓2号   版本V-0.0.1</p>
</div>
</body>

<script src="jquery/jquery-3.6.0.min.js"></script>
<script>
    jQuery(function () {

        jQuery("#btnSearch1").click(function () {
            let form=jQuery("#form").serialize();

            jQuery.post("student/search1",form,function (rst) {
                let trs='';

                for(let i=0;i<rst.length;i++)
                {
                    let u=rst[i];
                    trs+=`
                        <tr>
                            <td>${u.subjectNumber}</td>
                            <td>${u.subjectName}</td>
                            <td>${u.testScore}</td>
                            <td>${u.teacher}</td>

                        </tr>
                    `;
                }
                if(trs.length==0)
                {
                    trs=`
                         <tr>
                            <td colspan="4" class="text-center">成绩信息</td>
                        </tr>
                    `;
                }
                //把数据添加到tbody中
                jQuery("#tbody").html(trs);

            })
        });
    })

</script>
<script>
    jQuery(function () {
        let loc = location.href;
        let n1 = loc.length;
        let n2 = loc.indexOf("=");
        if (n2==-1) {
            location.href="userLogin.html";
        }
        let id = decodeURI(loc.substr(n2+1, n1-n2));
        jQuery("#homework").html(`
                    <a class="dropdown-item" href="studentFinishedHomework.html?id=${id}">已完成作业</a>
                    <a class="dropdown-item" href="studentSelectHomework.html?id=${id}">未完成作业</a>
        `);
        jQuery("#exam").html(`
                    <a class="dropdown-item" href="studentExaminationInformation.html?id=${id}">查询考试信息</a>
                    <a class="dropdown-item" href="studentScore.html?id=${id}">查询考试成绩</a>
        `)
    })
</script>

</html>
